package br.com.erpcortume.DAO;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import br.com.erpcortume.beans.Manifesto;
import br.com.erpcortume.repositorio.ManifestoRepositorio;

@Component
@Transactional
public class ManifestoDAO implements ManifestoRepositorio {

	private SessionFactory sf;
	
	@Autowired
	public ManifestoDAO(SessionFactory factory) {
		this.sf = factory;
		
	}
	
	public Session getSession(){
		return sf.getCurrentSession();
	}
	
	
	public void salvar(Manifesto manifesto) {
		 getSession().save(manifesto);		
	}

	@Override
	public List<Manifesto> listar() {
		return getSession().createCriteria(Manifesto.class).list();
	}
	
	
	

}
